<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                        <div class="col-sm-3" >
                            <div class="form-group form-inline" >
                                <%-- <input id="name" type="text" placeholder="请输入项目名称" class="input-sm form-control"  value="${position }"> --%>
                                <input id="workExpId" type="hidden" value="${workExpId }" />
                                <p class="help-block" style="color: red;">*如当前列表无数据，请新增后勾选确认。</p>
                       		    <a id="add_btn" class="btn btn-sm btn-primary" onclick="showadd();"> 新增</a>
                       		    <a id="sub_btn" class="btn btn-sm btn-warning" > 确认</a>
                             </div>
                        </div>
                    </div>
                </div>
                <!-- biaogebigin -->
                <input type="hidden" id="tempids" value="" />
		        <input type="hidden" id="tempnames" value="" />
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    $(top.hangge());
    var name = $("#name").val();
    var workExpId = $("#workExpId").val();
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/expProject/listData',
            datatype: "json",
            postData: {'name':name,'workExpId':workExpId}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
            	"id",
    			/* "所属工作", */
    			"项目名称",
    			"项目介绍",
    			"进入阶段",
    			"主要业绩",
    			/* "备注", */
    			"操作"],
            colModel: [
            	{name: "id",index: "id",hidden: true}, 
    			/* {name:"workExpId",index:"workExpId",width:100}, */
    			{name:"projectName",index:"projectName",width:150},
    			{name:"projectIntroduct",index:"projectIntroduct",width:100},
    			{name:"stage",index:"stage",width:100},
    			{name:"achievement",index:"achievement",width:100},
    			/* {name:"remark",index:"remark",width:100}, */
    			{
                    formatter: function (cellvalue, options, row) {
                        return " <s:hasPermission name="expProject:detail"><a class='btn btn-sm btn-info' title='查看' onclick='showeye(&quot;" + row.id + "&quot;)'><i class='icon-eye-open'></i></a></s:hasPermission> " 
                             + " <s:hasPermission name="expProject:edit"><a class='btn btn-sm btn-warning' title='修改' onclick='showedit(&quot;" + row.id + "&quot;)'><i class='icon-edit'></i></a></s:hasPermission> "
                             + " <s:hasPermission name="expProject:delete"><a class='btn btn-sm btn-danger' title='删除' onclick='del(&quot;" + row.id + "&quot;)'><i class='icon-trash'></i></a></s:hasPermission> ";
                    },
                    width: 150
                }],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
        	name = $("#name").val();
        	demandId = $("#id").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {'name': name,'id':demandId}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        $("#sub_btn").click(function() {
        	var selectedIds = $("#table_list").jqGrid("getGridParam", "selarrrow");
        	var tempid="";
        	var tempname="";
        	var rowdatas;
        	for (var i = 0; i < selectedIds.length; i++) {
        		rowdatas = $("#table_list").jqGrid("getRowData",selectedIds[i]);
        		tempid  += rowdatas.id+",";
        		tempname +=rowdatas.projectName+",";
			}
        	if(tempid==""){
        		swal({
  	    			title:"请选择一条数据",
  	    			text: "1秒后自动关闭。", 
  	    			timer: 1000, 
  				    showConfirmButton: false
  	    		});
        	}else {
        		$("#tempids").val(tempid);
            	$("#tempnames").val(tempname);
        		top.Dialog.close();
			}
		});
        
      //查看
        function showeye(id) {
            openyem("查看项目经验", "<%=contextPath%>/expProject/detailView?id=" + id, 550, 500);
        }
        //删除
        function del(id) {
            swalopen(id, "<%=contextPath%>/expProject/delete");
        };
        //修改
        function showedit(id) {
            openyem("修改项目经验", "<%=contextPath%>/expProject/editView?id=" + id, 550, 500);
        }
        //添加
        function showadd(id) {
            openyem("添加项目经验", "<%=contextPath%>/expProject/addView?workExpId="+workExpId, 550, 500);
        }
       function reset() {
		$("#name").val('');
		$("#id").val('');
       }
</script>
</body>
</html>

